package model

import org.apache.wicket.markup.html.basic.Label
import org.apache.wicket.markup.html.WebPage
import org.uqbar.wicket.xtend.WicketExtensionFactoryMethods
import model.AppModel.MapamundiAppModel
import org.apache.wicket.model.PropertyModel
import org.uqbar.wicket.xtend.XListView
import unq.model.Pais
import org.uqbar.wicket.xtend.XButton

/**
 * 
 * @author ?
 */
class HomePage extends WebPage {
	extension WicketExtensionFactoryMethods = new WicketExtensionFactoryMethods
	MapamundiAppModel model

	new() {
		
		this.model = new MapamundiAppModel
		val label = new Label("nombre", new PropertyModel(model, "nombre"))

		val list = new XListView("opciones", new PropertyModel(model, "opciones"))

		list.populateItem = [ item |
			item.model = item.modelObject.asCompoundModel
			item.addChild(new Label("nombre"))
			item.addChild(new XButton("ver").onClick = [|ver(item.modelObject)])
			
		]

		val listView = new XListView("caracteristicas", new PropertyModel(model, "caracteristicas"))
		listView.populateItem = [ item |
			item.model = item.modelObject.asCompoundModel
		]

		this.addChild(list)
		this.addChild(listView)
		this.addChild(label);

	}
	
	def ver(Pais p) {
		val listView = new XListView("caracteristicas", new PropertyModel(p, "caracteristicas"))
		listView.populateItem = [ item |
			item.model = item.modelObject.asCompoundModel
		]
		this.addChild(listView)
		
	}

	def editar(Object object) {
		throw new UnsupportedOperationException("TODO: auto-generated method stub")
	}
}
